import { searchItemList } from '@/services/item/item';

const ItemListModel = {
  namespace: 'itemList',
  state: {
    itemList: [],
  },
  effects: {
    *searchItemList({ payload }, { call, put }) {
      const response = yield call(searchItemList, payload);
      yield put({
        type: 'saveItemList',
        payload: response.data,
      });
    },
  },
  reducers: {
    saveItemList(state, action) {
      return { ...state, itemList: action.payload || [] };
    },
  },
};

export default ItemListModel;
